home *** CD-ROM | disk | FTP | other *** search
- 'Edit Field Tour
- 'A software explaination of the Text Edit Record
- 'WARNING: Some portions of this program do not
- 'function properly. USE AT YOUR OWN RISK!
- 'the ZBasic way.
- '©MacTutor, 1987
- 'By Dave Kelly
-
- WINDOW OFF
- COORDINATE WINDOW
- DEF MOUSE =-1
- DIM DestRect%(3)
- CALL GETWMGRPORT(WMgrPort&):'Figure out the size of monitor used
- PortRecttop=PEEK WORD(WMgrPort&+8)
- PortRectleft=PEEK WORD(WMgrPort&+10)
- PortRectbottom=PEEK WORD(WMgrPort&+12)
- PortRectright=PEEK WORD(WMgrPort&+14)
- WINDOW 1,"TEdit Tour",(PortRectleft+4,PortRecttop+42)-(PortRectright-6,PortRectbottom-6),5
- TEXT ,,,0
- EDIT FIELD 1,defaulttext$,(4,4)-(WINDOW(2)-16,WINDOW(3)/2),2
- SCROLL BUTTON 1,0,0,10,10,(WINDOW(2)-16,3)-(WINDOW(2),WINDOW(3)/2+1),0
- CALL MOVETO(4,(WINDOW(3)/2)+22)
- CALL DRAWSTRING("Change Byte:")
- EDIT FIELD 2,,(90,(WINDOW(3)/2)+13)-(105,(WINDOW(3)/2)+25)
- EFHndl2&=TEHANDLE(2)
- CALL MOVETO(111,(WINDOW(3)/2)+22)
- CALL DRAWSTRING("TO")
- EDIT FIELD 3,,(140,(WINDOW(3)/2)+13)-(155,(WINDOW(3)/2)+25)
- EFHndl3&=TEHANDLE(3)
- BUTTON 3,1,"Enter",(170,(WINDOW(3)/2)+11)-(240,(WINDOW(3)/2)+27)
- APPLE MENU "TEdit Tour"
- MENU 1,0,1,"File"
- MENU 1,1,1,"View Text Edit Record"
- MENU 1,2,0,"-"
- MENU 1,3,1,"Quit/Q"
- EDIT MENU 2
- DEF FN teWordPeek%(n)=PEEK WORD(PEEK LONG(TEHANDLE(1))+n)
- DEF FN teLongPeek&(n)=PEEK LONG(PEEK LONG(TEHANDLE(1))+n)
- EDIT FIELD 1:CurrentField=1
- ON DIALOG GOSUB "DialogEvent"
- ON MENU GOSUB "MenuEvent"
- FLUSHEVENTS
- MENU ON:DIALOG ON
- "Loop"
- GOSUB "Info"
- GOTO "Loop"
- MENU OFF:DIALOG OFF
- "DialogEvent"
- D=DIALOG(0)
- SELECT D
- CASE 1
- GOSUB "ButtonEvent"
- CASE 2
- 'EditEvent
- CurrentField=DIALOG(2)
- CASE 3
- 'Inactive Window
- CASE 4
- 'Closebox
- IF DIALOG(4)=1 THEN END
- CASE 5
- GOSUB "Refresh"
- CASE 6
- ' Return Key
- CurrentField=DIALOG(6)
- IF CurrentField<>1 THEN GOSUB "ButtonEvent"
- CASE 7
- ' Tab Key
- CurrentField=DIALOG(7)
- LONG IF CurrentField<>3
- EDIT FIELD CurrentField+1
- CurrentField=CurrentField+1
- XELSE
- EDIT FIELD 1
- CurrentField=1
- END IF
- CASE 8
- ' Zoomin not used
- CASE 9
- ' Zoomout not used
- CASE 10
- ' Shift tab
- CurrentField=DIALOG(10)
- LONG IF CurrentField<>1
- EDIT FIELD CurrentField-1
- CurrentField=CurrentField-1
- XELSE
- EDIT FIELD 3
- CurrentField=3
- END IF
- CASE 11
- ' Clear key
- CurrentField=DIALOG(11)
- CASE 12
- ' Left Arrow
- CurrentField=DIALOG(12)
- CASE 13
- ' Right Arrow
- CurrentField=DIALOG(13)
- CASE 14
- ' Up Arrow
- CurrentField=DIALOG(14)
- CASE 15
- ' Down Arrow
- CurrentField=DIALOG(15)
- CASE 16
- ' Keypress
- END SELECT
- RETURN
- "MenuEvent"
- MenuNumber=MENU(0)
- MenuItem=MENU(1)
- MENU
- SELECT MenuNumber
- CASE 255
- GOSUB "appleID"
- CASE 1
- GOSUB "fileID"
- CASE 2
- ' Edit Menu
- END SELECT
- RETURN
- "appleID"
- IF CurrentField<>1 THEN EDIT FIELD 1:CurrentField=1
- WINDOW 2,"",(PortRectleft+10,PortRecttop+30)-(PortRectright-12,PortRectbottom-12),-2
- TEXT 4,9,0,0
- MOUSE ON
- PRINT "Byte";SPC(5);"TEHANDLE = ";TEHANDLE(1)
- PRINT " 0 DestRect",FN teWordPeek%(0),FN teWordPeek%(2),FN teWordPeek%(4),FN teWordPeek%(6)
- PRINT " 8 ViewRect",FN teWordPeek%(8),FN teWordPeek%(10),FN teWordPeek%(12),FN teWordPeek%(14)
- PRINT "16 SelRect",FN teWordPeek%(16),FN teWordPeek%(18),FN teWordPeek%(20),FN teWordPeek%(22)
- PRINT "24 LineHeight",FN teWordPeek%(24)
- PRINT "26 FontAscent",FN teWordPeek%(26)
- PRINT "28 SelPoint",FN teWordPeek%(28),FN teWordPeek%(30)
- PRINT "32 SelStart",FN teWordPeek%(32),,"Byte"
-
- PRINT "34 SelEnd",FN teWordPeek%(34),,"68 recallines",FN teWordPeek%(68)
- PRINT "36 Active",FN teWordPeek%(36),,"70 ClickStuff",FN teWordPeek%(70)
- PRINT "38 WordBreak",FN teLongPeek&(38),,"72 CrOnly",FN teWordPeek%(72)
- PRINT "42 ClickLoop",FN teLongPeek&(42),,"74 txFont",FN teWordPeek%(74)
- PRINT "46 ClickTime",FN teLongPeek&(46),,"76 txFace",FN teWordPeek%(76)
- PRINT "50 ClickLoc",FN teWordPeek%(50),,"78 txMode",FN teWordPeek%(78)
- PRINT "52 Carettime",FN teLongPeek&(52),,"80 txSize",FN teWordPeek%(80)
- PRINT "56 CaretState",FN teWordPeek%(56),,"82 GrafPtr",FN teLongPeek&(82)
- PRINT "58 Just",FN teWordPeek%(58),,"86 HighHook",FN teLongPeek&(86)
- PRINT "60 teLength",FN teWordPeek%(60),,"90 caretHook",FN teLongPeek&(88)
- PRINT "62 hText",FN teLongPeek&(62),,"94 nLines",FN teWordPeek%(94)
- PRINT "66 RecalBack",FN teWordPeek%(66),,"96 LineStarts",FN teWordPeek%(96)
- PRINT
- TEXT 2,18
- PRINT SPC(15);"©MacTutor, 1987
- TEXT 2,12
- PRINT SPC(30);"By Dave Kelly"
- PRINT SPC(27);"ZBasic Version 4.0"
- MOUSE ON
- DO
- mous=MOUSE(0)
- outsiderect=(MOUSE(1)<0 OR MOUSE(1)>WINDOW(2) OR MOUSE(2)<0 OR MOUSE(2)>WINDOW(3))
- UNTIL mous<>0 AND NOT (outsiderect)
- MOUSE OFF
- WINDOW CLOSE 2
- TEXT 4,9,0,0
- GOSUB "Refresh"
- RETURN
- "fileID"
- SELECT MenuItem
- CASE 1
- GOSUB "appleID"
- CASE 3
- END
- END SELECT
- RETURN
- "Info"
- LONG IF CurrentField=1 AND WINDOW(0)=1
- TEXT 4,9,0,0
- PRINT @(0,17);"destRect:",FN teWordPeek(0),FN teWordPeek(2),FN teWordPeek(4),FN teWordPeek(6)
- PRINT @(0,18);"viewRect:",FN teWordPeek(8),FN teWordPeek(10),FN teWordPeek(12),FN teWordPeek(14)
- PRINT @(0,19);"selPoint:",FN teWordPeek(28),FN teWordPeek(30),
- PRINT @(0,20);"selStart:",FN teWordPeek(32),"selEnd:",FN teWordPeek(34)
- PRINT @(0,22);"teLength:",FN teWordPeek(60),"nLines: ";FN teWordPeek(94),"hText",PEEK LONG(FN teLongPeek&(62))
- PRINT @(0,23);"txFont:",FN teWordPeek(74),"txFace: ";FN teWordPeek(76),"txSize:",FN teWordPeek(80)
- END IF
- RETURN
- "Refresh"
- CALL TEXTFONT(4)
- CALL TEXTSIZE(9)
- CALL MOVETO(4,(WINDOW(3)/2)+22)
- CALL DRAWSTRING("Change Byte:")
- CALL MOVETO(111,(WINDOW(3)/2)+22)
- CALL DRAWSTRING("TO")
- RETURN
- "ButtonEvent"
- Byte$=EDIT$(2):NewByte$=EDIT$(3)
- FOR i= 1 TO LEN(Byte$)
- IF MID$(Byte$,i,1)<"0" OR MID$(Byte$,i,1)>"9"THEN Byte$=""
- NEXT i
- FOR i=1 TO LEN(NewByte$)
- IF MID$(NewByte$,i,1)<"0" OR MID$(NewByte$,i,1)>"9"THEN NewByte$=""
- NEXT i
- IF Byte$="" OR NewByte$="" THEN RETURN
- Byte&=VAL(Byte$):NewByte&=VAL(NewByte$)
- 'Delete current text (BOMBS see discussion in MacTutor, Nov. 87)
- 'CALL TESETSELECT(0,1000,EFHndl3&)
- 'CALL TEDELETE(EFHndl2&)
- 'CALL TESETSELECT(0,1000,EFHndl3&)
- 'CALL TEDELETE(EFHndl3&)
- EDIT FIELD 1:CurrentField=1
- POKE WORD PEEK LONG(TEHANDLE(1))+Byte&,NewByte&
- CALL SETRECT(DestRect%(0),FN teWordPeek(0),FN teWordPeek(2),FN teWordPeek(4),FN teWordPeek(6))
- CALL TEUPDATE(DestRect%(0),TEHANDLE(1))
- RETURN
-